<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<%@ taglib prefix="s" uri="/struts-tags"%>

<html>
<head>
<style>
div.scroll {
	width: 600px;
	/* height: 200px; */
	overflow-y: scroll;
}
</style>
</head>

<body>
	<%@ page
		import="universal.schema.action.*,java.util.*,universal.schema.model.*,com.opensymphony.xwork2.ActionContext"%>
	<div class="row-fluid">
		<div class="span10">
			<s:form>
				<!-- <div class="scroll"> -->
				<table class="table table-striped">
					<tr>
						<th>Information Regarding</th>
						<th>Select</th>
						<th align="center">Where Filters</th>
						<th align="center">Filter value</th>
						<th>Clear Condition</th>
						<th>Get Condition</th>
						<th align="center">Final Value</th>
						<th align="center" colspan="2">Connector</th>
					</tr>

					<!-- Nested s:iterator -->
					<s:iterator value="selectedNodesList">


						<s:iterator value="tblObj.columns">

							<% 
ArrayList<Node> list = (ArrayList<Node>)ActionContext.getContext().getSession().get("colslist");
int i=0;
//if(list!=null)
//{


//  for(int i=0;i<list.size();i++)
 // {
 %>
							<tr>
								<!-- showing all the non PK/FK columns -->
								<s:if test="%{dataType == 'NK'}">
									<td><s:property value="colName" /></td>
									<%-- <td><s:property value="dataType" /></td> --%>
									<td><s:checkbox name="checkColumns"
											fieldValue="%{colName}" value="%{colName in checkColumns}"
											theme="simple" /></td>

									<s:if
										test="%{colType == 'varchar' || colType == 'char' || colType == 'text'  || colType == 'longtext' || colType == 'mediumtext'}">
										<td><s:select theme="simple" name="operator"
												headerKey="-1" headerValue="Operator" list="str_op"
												id="opid" /></td>
									</s:if>
									<s:elseif test="%{colType == 'bool'}">
										<td><s:select theme="simple" name="operator"
												headerKey="-1" headerValue="Operator" list="bool_op"
												id="opid" /></td>
									</s:elseif>
									<s:elseif
										test="%{colType == 'tinyint' || colType == 'bigint' || colType == 'decimal' || 
											colType == 'double' || colType == 'int' || colType == 'smallint' || colType == 'float'}">
										<td><s:select theme="simple" name="operator"
												headerKey="-1" headerValue="Operator" list="int_op"
												id="opid" /></td>

									</s:elseif>

									<td><s:textfield theme="simple" name="where" size="10"
											id="whereid" /></td>
									<td><s:submit type="button" name="CLEAR" value="CLEAR"
											theme="simple" cssClass="btn" /></td>
									<td><s:submit type="button" name="save" value="SAVE"
											theme="simple" cssClass="btn btn-success" id="savvebtn"
											onclick="save()" /></td>

										<% i++;System.out.println("i="+i);//} %>

									<td><s:textfield name="concatcols" size="10"
											theme="simple" disabled="true" id="concatid" /></td>
									<td><s:hidden name="hide" theme="simple" /></td>
									<td><s:select theme="simple" name="filters"
											list="#{'AND':'AND','OR':'OR'}" /></td>

									<!-- <td> <s:select theme="simple" name="connector" headerKey="0" headerValue="Connector" list="#{'and':'AND','or':'OR'}"/> </td> -->
								</s:if>
							</tr>
							
						</s:iterator>
					</s:iterator>

				</table>
				<s:submit cssClass="btn btn-primary" value="Search" align="left"
					action="getResults" />
			</s:form>
		</div>
	</div>
</body>
<script type="text/javascript">
	function save() {
		var op = document.getElementById("opid");
		var val = document.getElementById("whereid");
		
		var str = op + " " + val;
		document.getElementByName("concatcols").display = 'none';
		document.getElementByName("concatcols").value = str;
		document.getElementByName("concatcols").display = 'block';
		//window.location = "searchTables";
	}
</script>

</html>